import React from 'react';
import {connect} from 'dva';
import styles from './index.less';
import { Badge } from 'antd-mobile';

const index = ({userInfo, gameResult}) => {
  let text = "";
  if(gameResult.DoneNum > 0){
    text = "已完成";
  }else if(gameResult.GameState === "DONE" && gameResult.DoneNum === 0){
    text = "未完成";
  }
  return (
    <div className={styles.header}>
      <Badge text={text} corner>
        <img src={userInfo.WXHeadUrl} alt=""/>
        <h3>{userInfo.WXName}</h3>
        <div className={styles.userid}>玩家编号：<span>{userInfo.UserNo}</span></div>
      </Badge>
    </div>
  )
};

export default connect(({user, card}) => ({
  userInfo: user.userInfo,
  gameResult: card.gameResult,
}))(index);
